home *** CD-ROM | disk | FTP | other *** search
- /*.h2 Aesthete™ */
- /*.fo ©1989 David Dunham */
- /*
- Install the DetachResource patch
- */
-
- #define global
- #include "aesthete.h"
- #include <pascal.h>
-
- void main() {
- Handle handle;
- Handle sicn, creators;
-
- asm {
- btst #0,0x17B ; check KeyMap+7 — is [Shift] key down?
- bne @noInstall ; yes — don’t install patch
- }
- handle = GetResource('INIT',0);
- DetachResource(handle); /* Detach ourselves */
- handle = GetResource('SHOW',0); /* Get a handle to the PROC */
- if (handle != 0L) { /* Loaded OK */
- HLock(handle); /* Hold down the PROC */
- CallPascal(128,-1,*handle); /* ShowICON() */
- HUnlock(handle); /* Let it float in the heap again */
- }
- asm {
- bra @around
- dc.l 0 ; for oldTrap
- dc.l 0 ; for creators handle
- dc.l 0 ; for sicn handle
- #define oldTrap -12
- #define oCreators -8
- #define oSicn -4
- myPatch:
- lea @myPatch,A0
- move.l oCreators(A0),-(SP)
- move.l oSicn(A0),-(SP)
- move.l 12(SP),A0 ; original parameter to _DetachResource
- move.l A0,-(SP)
- jsr aesthetize ; aesthetize(rsrc,sicn,creators)
- add.l #12,SP
- lea @myPatch,A0
- move.l oldTrap(A0),A0
- jmp (A0) ; pass the call to original _DetachResource
- _Debugger ; should never get here!
- }
- asm {
- around:
- }
- sicn = double_SICN(); /* Get double-size sicns */
- creators = GetResource('SIG#',0);
- DetachResource(creators);
- asm {
- move.w #0xA992,D0
- _GetTrapAddress
- lea @myPatch,A1
- move.l A0,oldTrap(A1) ; save original trap address
- lea @myPatch,A0
- move.w #0xA992,D0
- _SetTrapAddress ; install our patch
- lea @myPatch,A0
- move.l sicn,oSicn(A0) ; stash it
- move.l creators,oCreators(A0)
- noInstall:
- }
- }
-